package com.cc.wechat.exception;

import com.cc.wechat.common.ResultCode;
import lombok.Getter;

/**
 * 业务异常
 * 用于处理业务逻辑中的异常情况
 */
@Getter
public class BusinessException extends RuntimeException {
    
    /**
     * 错误码
     */
    private final ResultCode resultCode;

    /**
     * 错误消息
     */
    private final String message;

    /**
     * 使用ResultCode枚举构造异常
     * @param resultCode 错误码枚举
     */
    public BusinessException(ResultCode resultCode) {
        super(resultCode.getMessage());
        this.resultCode = resultCode;
        this.message = resultCode.getMessage();
    }

    /**
     * 使用ResultCode枚举和自定义消息构造异常
     * @param resultCode 错误码枚举
     * @param message 自定义错误消息
     */
    public BusinessException(ResultCode resultCode, String message) {
        super(message);
        this.resultCode = resultCode;
        this.message = message;
    }
} 